package cn.ekuma.epos.module;

import javax.swing.JPanel;
import java.awt.BorderLayout;
import javax.swing.JLabel;
import java.awt.Dimension;
import javax.swing.JTextField;
import javax.swing.JButton;

import com.openbravo.data.basic.BasicException;

import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;

public class ModuleEntryPanel extends JPanel {
	private JTextField name;
	private JTextField majorVersion;
	private JTextField minorVersion;

	private JLabel memo;
	private JButton btnInsert;
	private JButton btnUnInsert;
	private JButton btnMemo;
	
	/**
	 * Create the panel.
	 */
	public ModuleEntryPanel() {
		initComponents();
	}
	
	public void init(){
	
	}
	
	
	private void initComponents() {
		setLayout(new BorderLayout(0, 0));
		
		JPanel panel = new JPanel();
		panel.setPreferredSize(new Dimension(120, 25));
		add(panel, BorderLayout.NORTH);
		panel.setLayout(null);
		
		name = new JTextField();
		name.setEditable(false);
		name.setBounds(0, 0, 136, 21);
		panel.add(name);
		name.setColumns(10);
		
		majorVersion = new JTextField();
		majorVersion.setEditable(false);
		majorVersion.setBounds(143, 0, 54, 21);
		panel.add(majorVersion);
		majorVersion.setColumns(10);
		
		minorVersion = new JTextField();
		minorVersion.setEditable(false);
		minorVersion.setBounds(206, 0, 59, 21);
		panel.add(minorVersion);
		minorVersion.setColumns(10);
		
	    btnInsert = new JButton("安装");
	    btnInsert.addActionListener(new ActionListener() {
	    	public void actionPerformed(ActionEvent e) {
	    		insertActionPerformed(e);
	    	}
	    });
		btnInsert.setBounds(278, -1, 68, 23);
		panel.add(btnInsert);
		
		 btnUnInsert = new JButton("卸载");
		btnUnInsert.setBounds(352, -1, 68, 23);
		btnUnInsert.addActionListener(new ActionListener() {
	    	public void actionPerformed(ActionEvent e) {
	    		unInsertActionPerformed(e);
	    	}
	    });
		panel.add(btnUnInsert);
		
	    btnMemo = new JButton("说明");
	    btnMemo.addActionListener(new ActionListener() {
	    	public void actionPerformed(ActionEvent e) {
	    		btnMemoActionPerformed(e);
	    	}
	    });
		btnMemo.setBounds(508, -1, 68, 23);
		panel.add(btnMemo);
		
	    memo = new JLabel("New label");
	    memo.setVisible(false);
		add(memo, BorderLayout.CENTER);
	}

	protected void unInsertActionPerformed(ActionEvent e) {
		
		
	}

	protected void insertActionPerformed(ActionEvent e) {
		
	}

	
	
	protected void btnMemoActionPerformed(ActionEvent e) {
		memo.setVisible(memo.isVisible());	
	}
}
